<template>
  <div>
     <h3 class="dialog-plate-title mt-1"><span>当日检测</span></h3>
     <el-form :inline="true" :model="formData" :rules="dialogRules" ref="dialogRules" label-width="120px" class="demo-ruleForm">
        <el-form-item label="胸部" prop="chest">
          <el-select v-model="formData.chest" class="width220">
            <el-option label="正常" :value="1">正常</el-option>
            <el-option label="不正常" :value="0">不正常</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="腹部" prop="abdomen" >
          <el-select v-model="formData.abdomen"  class="width220">
            <el-option label="正常" :value="1">正常</el-option>
            <el-option label="不正常" :value="0">不正常</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="皮肤" prop="skin" >
          <el-select v-model="formData.skin"  class="width220">
            <el-option label="正常" :value="1">正常</el-option>
            <el-option label="不正常" :value="0">不正常</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="四肢" prop="facial" >
          <el-select v-model="formData.facial"  class="width220">
            <el-option label="正常" :value="1">正常</el-option>
            <el-option label="不正常" :value="0">不正常</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="五官" prop="limbs">
          <el-select v-model="formData.limbs"  class="width220">
            <el-option label="正常" :value="1">正常</el-option>
            <el-option label="不正常" :value="0">不正常</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="remark" class="form-item-block">
         <el-input type="textarea" :rows="2" placeholder="请输入备注" v-model="formData.remark" class="width520"/>
       </el-form-item>
        <el-form-item label="检测医师">
          <el-input v-model="formData.creatorName" disabled  class="width220"></el-input>  
        </el-form-item>
        <el-form-item label="检测时间">
          <el-input :value="timestampToTime(formData.createTime,'yyyy-mm-dd hh:mm:ss')" disabled  class="width220"></el-input>             
        </el-form-item>
        <el-form-item class="form-item-block text-center">
          <el-button type="primary" @click="submitTodayCase">提交</el-button>           
        </el-form-item>
      </el-form>
      <h3 class="dialog-plate-title mt-1"><span>历史记录</span></h3>
        <el-table :data="tableHistoryData" stripe border class="company-table" style="width: 95%;">
          <el-table-column prop="chest" label="胸部" sortable min-width="90">
            <template slot-scope="scope">
              {{scope.row.chest==0?'不正常':'正常'}}
            </template>
          </el-table-column>
          <el-table-column prop="abdomen" label="腹部" sortable min-width="110">
            <template slot-scope="scope">
              {{scope.row.abdomen==0?'不正常':'正常'}}
            </template>
          </el-table-column>
          <el-table-column prop="skin" label="皮肤" sortable min-width="110">
            <template slot-scope="scope">
              {{scope.row.skin==0?'不正常':'正常'}}
            </template>
          </el-table-column>
          <el-table-column prop="limbs" label="四肢" sortable min-width="110">
            <template slot-scope="scope">
              {{scope.row.limbs==0?'不正常':'正常'}}
            </template>
          </el-table-column>
          <el-table-column prop="facial" label="五官" sortable min-width="110">
            <template slot-scope="scope">
              {{scope.row.facial==0?'不正常':'正常'}}
            </template>
          </el-table-column>
          <el-table-column prop="remark" label="备注" sortable min-width="110" />
          <el-table-column prop="creatorName" label="检测医师" sortable min-width="110" />
          <el-table-column prop="createTime" label="检测日期" sortable min-width="110">
            <template slot-scope="scope">
              {{timestampToTime(scope.row.createTime,'yyyy-mm-dd hh:mm:ss')}}
            </template>
          </el-table-column>
        </el-table> 
  </div>
</template>
<script>
import {getPhysicalExaminationHistory,getPhysicalExaminationToday,updatePhysicalExaminationToday} from "plugins/axios/inquiryRecord.js"
export default {
  props:{
    pid:{
      type:[String,Number]
    },
    providerId:{
      type:[String,Number]
    }
  },
  data(){
    return {
      formData:{},
      dialog:{},
      tableHistoryData:[],
      dialogRules: {
        chest: [
          { required: true, message: "请选择胸部情况", trigger: "blur" }
        ],
        abdomen: [
          { required: true, message: "请选择腹部情况", trigger: "blur" }
        ],
        skin: [
          { required: true, message: "请选择皮肤情况", trigger: "blur" }
        ],
        facial: [
          { required: true, message: "请选择四肢情况", trigger: "blur" }
        ],
        limbs: [
          { required: true, message: "请选择五官情况", trigger: "blur" }
        ]
      },
    }
  },
  created(){},
  mounted(){},
  watch:{},
  computed:{},
  methods:{
    init(){
      this.getPhysicalExaminationHistory();
      this.getPhysicalExaminationToday();
    },
    submitTodayCase(){
      let self= this;
      let postData = {...self.formData};
      postData.hid=postData.hid?postData.hid:self.pid;
      debugger;
      updatePhysicalExaminationToday(postData).then(res=>{
        self.$message.success("提交成功");
        self.init();
      })
    },
    getPhysicalExaminationHistory(){
      let self = this;
      getPhysicalExaminationHistory(self.providerId).then(res=>{
        self.tableHistoryData = res.content;
      })
    },
    getPhysicalExaminationToday(){
      let self = this;
      getPhysicalExaminationToday(self.pid).then(res=>{
          self.formData ={...res.content} ;
      });
    },
  }
}
</script>
<style scoped>
</style>